<template>
	<view class="home">
		<my-header sticky :scrollTop="scrollTop"></my-header>
		<view class="menu-bg">
			<view class="menu">
				<view class="menu-item" v-for="(item, index) in menuList" :key="index">
					<image class="image" :src="item.url"></image>
					<text>{{ item.title }}</text>
				</view>
			</view>
		</view>
		<view class="swiper">
			<my-swiper :swiperList="swiperList" height="100px"></my-swiper>
		</view>

		<view class="list">
			<view class="list-item" v-for="(item, index) in list" :key="index">
				<view class="list-item-box">
					<image :src="item.picUrl" mode="widthFix"></image>
					<view class="content">
						<text class="title">{{item.title}}</text>
						<text class="tag">{{item.bigBrightPointDesc}}</text>
						<view class="btm">
							<view class="price">{{item.pricePrefix}}:{{item.priceValue}}{{item.priceSuffix}}</view>
							<view class="sell">{{item.dynamicsInfo}}</view>
							<uni-icons></uni-icons>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList: [
					'../../static/images/banner/1.png',
					'../../static/images/banner/2.png',
					'../../static/images/banner/3.png',
					'../../static/images/banner/4.png',
				],
				scrollTop: 0,
				menuList: new Array(10).fill().map(v => {
					return {
						url: '../../static/images/home/menu.png',
						title: '标题'
					}
				}),
				page: 1,
				list: []
			};
		},
		computed: {
			params() {
				return {
					// type: originaljson,
					// api: mtop.fliggy.ssif.pattern.home
					// v: 1.0
					// data: {
					// 	"bizType": "homepage",
					// 	"name": "fliggy_home_guess_you_like_miniapp_new",
					// 	"version": "1.0.0",
					// 	"platform": "h5",
					// 	"args": "{\"source\":\"miniapp\",\"useNewTrackArgs\":\"1\",\"params\":{\"spmabc\":\"181.27203027.1998936340\",\"fromType\":\"CombDxGuessLike\",\"initPageNo\":0,\"gulTabId\":\"1\",\"algoParams\":{\"tabId\":\"1\",\"isTraveling\":\"false\",\"tabTypeInfo\":\"GUSSETAB\",\"appid\":16051,\"lbsCity\":\"\",\"tabType\":\"ALL\",\"isPreloadTab\":true,\"isMainTab\":true,\"tairKey\":\"GULTAB_1_0_0_2_1\",\"selectedTab\":1},\"pageNo\":" + this.page + "}}",
					// 	"isLocationPermission": false,
					// 	"h5Version": "2.0.8"
					// }
					// ttid: 201300 @travel_h5_3 .1 .0
					// appKey: 12574478
					// t: 1700655819315
					// sign: 3695 b22b2e3fe6ed26d0202dba30c37e
				}
			}
		},
		methods: {
			getList() {
				uni.request({
					url: 'http://localhost:3000/list',
				}).then(([err, resp]) => {
					const data = resp.data.map(v => {
						return v.items[0]
					})
					console.log(JSON.parse(JSON.stringify(data)))
					this.list = data
				})
			},
			getFZList() {
				uni.request({
					url: 'https://h5api.m.taobao.com/h5/mtop.fliggy.ssif.pattern.home/1.0',
				}).then(resp => {
					console.log(resp)
				})
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop
		},
		onLoad() {
			this.getList();
			this.getFZList()
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		column-count: 2;
		column-gap: 0;

		.list-item {
			width: 100%;
			padding: 10rpx;
			box-sizing: border-box;
			// 不要这行

			.list-item-box {
				border-radius: 30rpx;
				overflow: hidden;
				background-color: white;
				border: 2rpx solid #ccc;

				image {
					width: 100%;
				}

				.content {
					padding: 10rpx;

					.title {
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
					}
				}

			}


		}
	}

	.home {
		background-color: white;
	}

	.swiper {
		width: 96%;
		margin: 20upx auto;
		border-radius: 20upx;
		overflow: hidden;
	}

	.menu-bg {
		display: flex;
		justify-content: center;
		background-image: url(../../static/images/home/bg.webp);
		background-size: 100% 100%;

		.menu {
			// background-color: rgba(166, 166,166,  .3);
			background-image: url(../../static/images/home/menubg.png);
			background-size: 100% 100%;
			margin: 40upx;
			border-radius: 20upx;
			width: 90%;
			overflow: hidden;
			display: flex;
			flex-wrap: wrap;

			.menu-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-around;
				width: 20%;
				height: 80px;

				.image {
					width: 30px;
					height: 30px;
				}
			}
		}
	}
</style>